results=c()
for(i in 1:c(length(yrs))){
results[i] <- weighted.mean(a$unempjob[which(a$country==cntry & a$year==yrs[i])],
w=a$weight[which(a$country==cntry & a$year==yrs[i])],na.rm=T)
}
results
}
m1 <- meanump("Austria",c(1990,1999,2008))
m2 <- meanump("Belgium",c(1990,1999,2009))
#m3 <- meanump("Bulgaria",c(1990,1999,2008))
m4 <- meanump("Denmark",c(1990,1999,2008))
m5 <- meanump("Finland",c(1990,2000,2009))
m6 <- meanump("France",c(1990,1999,2008))
m7 <- meanump("Germany",c(1990,1999,2008))
#m8 <- meanump("Hungary",c(1991,1999,2008))
m9 <- meanump("Ireland",c(1990,1999,2008))
m10 <- meanump("Italy",c(1990,1999,2009))
#m11 <- meanump("Latvia",c(1990,1999,2008))
#m12 <- meanump("Lithuania",c(1990,1999,2008))
m13 <- meanump("Netherlands",c(1990,1999,2008))
#m14 <- meanump("Poland",c(1990,1999,2008))
m15 <- meanump("Portugal",c(1990,1999,2008))
m16 <- meanump("Spain",c(1990,1999,2008))
#m17 <- meanump("Slovakia",c(1990,1999,2008))
m18 <- meanump("Sweden",c(1990,1999,2009))
m19 <- meanump("Great Britain",c(1990,1999,2009))
x <- a$unempjob[which(a$country=="Austria" & a$year==c(1990,1999,2008))]
a$unempjob[which(a$country=="Austria" & a$year==c(1990,1999,2008))]
load("C:/Users/Uctqtdo/Dropbox/Book Manuscript/code and data/Chapters 1 and 2/180905_econ_maindata.Rda")
a <- econ_data
a$country <- as.character(a$country)
a$useweight <- as.numeric(a$weight)
m1 <- meanump("Austria",c(1990,1999,2008))
m2 <- meanump("Belgium",c(1990,1999,2009))
#m3 <- meanump("Bulgaria",c(1990,1999,2008))
m4 <- meanump("Denmark",c(1990,1999,2008))
m5 <- meanump("Finland",c(1990,2000,2009))
m6 <- meanump("France",c(1990,1999,2008))
m7 <- meanump("Germany",c(1990,1999,2008))
#m8 <- meanump("Hungary",c(1991,1999,2008))
m9 <- meanump("Ireland",c(1990,1999,2008))
m10 <- meanump("Italy",c(1990,1999,2009))
#m11 <- meanump("Latvia",c(1990,1999,2008))
#m12 <- meanump("Lithuania",c(1990,1999,2008))
m13 <- meanump("Netherlands",c(1990,1999,2008))
#m14 <- meanump("Poland",c(1990,1999,2008))
m15 <- meanump("Portugal",c(1990,1999,2008))
m16 <- meanump("Spain",c(1990,1999,2008))
#m17 <- meanump("Slovakia",c(1990,1999,2008))
m18 <- meanump("Sweden",c(1990,1999,2009))
m19 <- meanump("Great Britain",c(1990,1999,2009))
pdf(file="C:/Users/Uctqtdo/Dropbox/Book Manuscript/chapters/figuresx/comp_opinion2.pdf",
width=4,height=4.5)
plot(m1,
type="l",
lty=3,
ylim=c(4,8),
xaxt="n",
las=2,
ylab="Mean Response (1-10 Scale)",
xlab="",
cex.lab=0.7,
cex.axis=0.7)
lines(m2,type="l",lty=3)
lines(m3,type="l",lty=3)
lines(m4,type="l",lty=3)
lines(m5,type="l",lty=3)
lines(m6,type="l",lty=3)
lines(m7,type="l",lty=3)
lines(m8,type="l",lty=3)
lines(m9,type="l",lty=3)
lines(m10,type="l",lty=3)
lines(m11,type="l",lty=3)
lines(m12,type="l",lty=3)
lines(m13,type="l",lty=3)
lines(m14,type="l",lty=3)
lines(m15,type="l",lty=3)
lines(m16,type="l",lty=3)
lines(m17,type="l",lty=3)
lines(m18,type="l",lty=3)
lines(m19,type="l",lwd=2,col="red")
axis(1,at=c(1,2,3),labels=c("1990","1999/2000","2008/09"),cex.axis=0.7)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.33,-0.85, c("Other European Countries","Great Britain"),
xpd = TRUE, inset = c(0,0), lty=c(3,1),lwd=c(1,2),col=c("black","red"),cex = 0.6)
dev.off()
pdf(file="C:/Users/Uctqtdo/Dropbox/Book Manuscript/chapters/figuresx/comp_opinion2.pdf",
width=4,height=4.5)
plot(m1,
type="l",
lty=3,
ylim=c(4,8),
xaxt="n",
las=2,
ylab="Mean Response (1-10 Scale)",
xlab="",
cex.lab=0.7,
cex.axis=0.7)
lines(m2,type="l",lty=3)
#lines(m3,type="l",lty=3)
lines(m4,type="l",lty=3)
lines(m5,type="l",lty=3)
lines(m6,type="l",lty=3)
lines(m7,type="l",lty=3)
#lines(m8,type="l",lty=3)
lines(m9,type="l",lty=3)
lines(m10,type="l",lty=3)
#lines(m11,type="l",lty=3)
#lines(m12,type="l",lty=3)
lines(m13,type="l",lty=3)
#lines(m14,type="l",lty=3)
lines(m15,type="l",lty=3)
lines(m16,type="l",lty=3)
#lines(m17,type="l",lty=3)
lines(m18,type="l",lty=3)
lines(m19,type="l",lwd=2,col="red")
axis(1,at=c(1,2,3),labels=c("1990","1999/2000","2008/09"),cex.axis=0.7)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.33,-0.85, c("Other European Countries","Great Britain"),
xpd = TRUE, inset = c(0,0), lty=c(3,1),lwd=c(1,2),col=c("black","red"),cex = 0.6)
dev.off()
# analysis of BHPS
library(readstata13)
library(zoo)
b=read.dta13("C:/Users/Uctqtdo/Dropbox/Book Manuscript/code and data/Chapter 6/BHPS_panelR.dta",
convert.factors=F)
### REVERSE FIVE-POINT SCALE ###
fivept <- function(v){
a <- rep(NA, length(v))
a[which(as.numeric(v)==5)] <- 1
a[which(as.numeric(v)==4)] <- 2
a[which(as.numeric(v)==3)] <- 3
a[which(as.numeric(v)==2)] <- 4
a[which(as.numeric(v)==1)] <- 5
return(a)
}
b$jobs <- fivept(b$govjobs)
bgj <- subset(b,b$end>13&b$jobs>0)
bgjwaves <- c(1,3,5,7,10,14,17)
bgj.1m=bgj.1p=bgj.2m=bgj.2p=bgj.4m=bgj.4p=bgj.6m=bgj.6p=c()
# began in wave 1
for(i in c(1:7)){
bgj.1p[i] <- length(bgj$jobs[which(bgj$start==1 & bgj$jobs>3 & bgj$wave==bgjwaves[i])]) /
length(bgj$jobs[which(bgj$start==1 & bgj$wave==bgjwaves[i])])
}
# began in wave 2-3
for(i in c(2:7)){
bgj.2p[i-1] <- length(bgj$jobs[which( (bgj$start==2|bgj$start==3) & bgj$jobs>3 & bgj$wave==bgjwaves[i])]) /
length(bgj$jobs[which((bgj$start==2|bgj$start==3) & bgj$wave==bgjwaves[i])])
}
# began in wave 4-5
for(i in c(3:7)){
bgj.4p[i-2] <- length(bgj$jobs[which( (bgj$start==4|bgj$start==5) & bgj$jobs>3 & bgj$wave==bgjwaves[i])]) /
length(bgj$jobs[which((bgj$start==4|bgj$start==5) & bgj$wave==bgjwaves[i])])
}
# began in wave 6-7
for(i in c(4:7)){
bgj.6p[i-3] <- length(bgj$jobs[which( (bgj$start==6|bgj$start==7) & bgj$jobs>3 & bgj$wave==bgjwaves[i])]) /
length(bgj$jobs[which((bgj$start==6|bgj$start==7) & bgj$wave==bgjwaves[i])])
}
# Plotting percents
bgj.1p.plot <- c(bgj.1p[1],NA,bgj.1p[2],NA,bgj.1p[3],NA,bgj.1p[4],NA,NA,bgj.1p[5],
NA,NA,NA,bgj.1p[6],NA,NA,bgj.1p[7])
bgj.2p.plot <- c(bgj.2p[1],NA,bgj.2p[2],NA,bgj.2p[3],NA,NA,bgj.2p[4],
NA,NA,NA,bgj.2p[5],NA,NA,bgj.2p[6])
bgj.4p.plot <- c(bgj.4p[1],NA,bgj.4p[2],NA,NA,bgj.4p[3],
NA,NA,NA,bgj.4p[4],NA,NA,bgj.4p[5])
bgj.6p.plot <- c(bgj.6p[1],NA,NA,bgj.6p[2],
NA,NA,NA,bgj.6p[3],NA,NA,bgj.6p[4])
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.6,
xlab="",xaxt="n",main="Government Should Provide Jobs",cex.main=0.6,cex.axis=0.6)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.6,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=0.6)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-0.75, c("Began Wave 1 or 1-2","Began Waves 2-3 or 3-4",
"Began Waves 4-5 or 5-6","Began waves 6-7 or 7-8"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.5,ncol=2)
pdf(file="C:/Users/tomdo/Dropbox/Book Manuscript/chapters/figuresx/bhps_overtime1.pdf",
height=4,width=4.5)
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.6,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=0.6)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-0.75, c("Began Wave 1 or 1-2","Began Waves 2-3 or 3-4",
"Began Waves 4-5 or 5-6","Began waves 6-7 or 7-8"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.5,ncol=2)
dev.off()
pdf(file="C:/Users/Uctqtdo/Dropbox/Book Manuscript/chapters/figuresx/bhps_overtime1.pdf",
height=4,width=4.5)
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.6,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=0.6)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-0.75, c("Began Wave 1 or 1-2","Began Waves 2-3 or 3-4",
"Began Waves 4-5 or 5-6","Began waves 6-7 or 7-8"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.5,ncol=2)
dev.off()
?par
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.6,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=0.6)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(-1, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-0.75, c("Began Wave 1","Began Waves 2-3",
"Began Waves 4-5","Began waves 6-7"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.5,ncol=2)
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.6,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=0.6)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-0.75, c("Began Wave 1","Began Waves 2-3",
"Began Waves 4-5","Began waves 6-7"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.5,ncol=2)
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.6,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=0.6)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(2, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-0.75, c("Began Wave 1","Began Waves 2-3",
"Began Waves 4-5","Began waves 6-7"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.5,ncol=2)
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.6,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=0.6)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(-1, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-0.75, c("Began Wave 1","Began Waves 2-3",
"Began Waves 4-5","Began waves 6-7"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.5,ncol=2)
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.6,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=0.6)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(1, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-0.75, c("Began Wave 1","Began Waves 2-3",
"Began Waves 4-5","Began waves 6-7"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.5,ncol=2)
pdf(file="C:/Users/Uctqtdo/Dropbox/Book Manuscript/chapters/figuresx/bhps_overtime1.pdf",
height=4,width=4.5)
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.6,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=0.6)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-0.75, c("Began Wave 1","Began Waves 2-3",
"Began Waves 4-5","Began waves 6-7"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.5)
dev.off()
pdf(file="C:/Users/Uctqtdo/Dropbox/Book Manuscript/chapters/figuresx/bhps_overtime1.pdf",
height=4,width=4.5)
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.6,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=0.6)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-0.75, c("Began Wave 1","Began Waves 2-3",
"Began Waves 4-5","Began waves 6-7"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.5,ncol=4)
dev.off()
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.6,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=0.6)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-1, c("Began Wave 1","Began Waves 2-3",
"Began Waves 4-5","Began waves 6-7"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.5,ncol=2)
pdf(file="C:/Users/Uctqtdo/Dropbox/Book Manuscript/chapters/figuresx/bhps_overtime1.pdf",
height=4,width=4.5)
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.6,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=0.6)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-0.85, c("Began Wave 1","Began Waves 2-3",
"Began Waves 4-5","Began waves 6-7"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.5,ncol=2)
dev.off()
length(bgj$jobs[which(bgj$start==1 & bgj$wave==bgjwaves[i])])
length(bgj$jobs[which((bgj$start==2|bgj$start==3) & bgj$wave==bgjwaves[i])])
length(bgj$jobs[which((bgj$start==4|bgj$start==5) & bgj$wave==bgjwaves[i])])
length(bgj$jobs[which((bgj$start==6|bgj$start==7) & bgj$wave==bgjwaves[i])])
length(bgj$jobs[which((bgj$start==2) & bgj$wave==bgjwaves[i])])
length(bgj$jobs[which((bgj$start==4|bgj$start==5) & bgj$wave==bgjwaves[i])])
length(bgj$jobs[which((bgj$start==4) & bgj$wave==bgjwaves[i])])
length(bgj$jobs[which((bgj$start==7) & bgj$wave==bgjwaves[i])])
351+308+336
pdf(file="C:/Users/Uctqtdo/Dropbox/Book Manuscript/chapters/figuresx/bhps_overtime1.pdf",
height=4,width=4.5)
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=1,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=1)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.6)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-0.85, c("Began Wave 1","Began Waves 2-3",
"Began Waves 4-5","Began waves 6-7"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.5,ncol=2)
dev.off()
pdf(file="C:/Users/Uctqtdo/Dropbox/Book Manuscript/chapters/figuresx/bhps_overtime1.pdf",
height=4,width=4.5)
par(mar=c(5,4,3,2))
plot(na.approx(bgj.1p.plot),type="l",ylim=c(0.35,0.65),las=1,ylab="Percent Agreeing",cex.lab=0.8,
xlab="",xaxt="n",main="",cex.main=0.6,cex.axis=0.8)
axis(1,at=c(1,4,7,10,13,16),labels=c(1991,1994,1997,2000,2003,2006),
cex.axis=0.8)
points(bgj.1p.plot,pch=16,cex=0.5)
lines(c(NA,NA,na.approx(bgj.2p.plot)),type="l",lty=3,lwd=1.3)
points(c(NA,NA,bgj.2p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,na.approx(bgj.4p.plot)),type="l",lty=5)
points(c(NA,NA,NA,NA,bgj.4p.plot),pch=16,cex=0.5)
lines(c(NA,NA,NA,NA,NA,NA,na.approx(bgj.6p.plot)),type="l",lty=4)
points(c(NA,NA,NA,NA,NA,NA,bgj.6p.plot),pch=16,cex=0.5)
par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
plot(0, 0, type = "n", bty = "n", xaxt = "n", yaxt = "n")
legend(-0.42,-0.85, c("Began Wave 1","Began Waves 2-3",
"Began Waves 4-5","Began waves 6-7"),
xpd = TRUE, inset = c(0,0), lty=c(1,3,5,4),cex = 0.6,ncol=2)
dev.off()
dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, "Makevars.win")
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native",
"CXX14 = g++ -m$(WIN) -std=c++1y",
"CXX11FLAGS=-O3 -march=native",
file = M, sep = "\n", append = TRUE)
remove.packages(c("StanHeaders", "rstan"))
install.packages("StanHeaders", repos = c('https://mc-stan.org/r-packages/', getOption("repos")))
install.packages("rstan", repos = c('https://mc-stan.org/r-packages/', getOption("repos")))
dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, "Makevars.win")
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native",
"CXX14 = g++ -m$(WIN) -std=c++1y",
"CXX11FLAGS=-O3 -march=native",
file = M, sep = "\n", append = TRUE)
remove.packages(c("StanHeaders", "rstan"))
remove.packages(c("StanHeaders"))
install.packages("rstan", repos = c('https://mc-stan.org/r-packages/', getOption("repos")))
remove.packages(c("StanHeaders", "rstan"))
dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, "Makevars.win")
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native",
"CXX14 = C:/Rtools/mingw_64/g++.exe -m$(WIN) -std=c++1y",
"CXX11FLAGS=-O3 -march=native",
file = M, sep = "\n", append = TRUE)
install.packages("StanHeaders", repos = c('https://mc-stan.org/r-packages/', getOption("repos")))
install.packages("rstan", repos = c('https://mc-stan.org/r-packages/', getOption("repos")))
###### Estimating Support for Democracy
###### Running Stan Models
###### v3: 1988-2019
dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, "Makevars.win")
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native",
"CXX14 = C:/Rtools/mingw_64/bin/g++.exe -m$(WIN) -std=c++1y",
"CXX11FLAGS=-O3 -march=native",
file = M, sep = "\n", append = TRUE)
remove.packages(c("StanHeaders", "rstan"))
install.packages("StanHeaders", repos = c('https://mc-stan.org/r-packages/', getOption("repos")))
install.packages("rstan", repos = c('https://mc-stan.org/r-packages/', getOption("repos")))
remove.packages("rtools")
remove.packages("Rtools")
install.packages('Rtools')
library(readstata13)
"C:/Users/Uctqtdo/Dropbox/PACER team/CovidIdeology/CovidIdeologyReplication/source_data"
library(foreign)
besnov21 <- read.dta("BES2019_W21_Panel_v21.0.dta")
getwd()
"C:/Users/Uctqtdo/Dropbox/PACER team/CovidIdeology/"
setwd("C:/Users/Uctqtdo/Dropbox/PACER team/CovidIdeology/CovidIdeologyReplication/source_data")
library(foreign)
besnov21 <- read.dta("BES2019_W21_Panel_v21.0.dta")
?read.dta
